<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    // 如果已经登录，跳转到首页
    if (session.getAttribute("user") != null) {
        response.sendRedirect(request.getContextPath() + "/index.jsp");
        return;
    }
%>
<!DOCTYPE html>
<html>
<head>
    <title>忘记密码</title>
    <link rel="stylesheet" href="<%= request.getContextPath() %>/assets/css/styles.css">
</head>
<body>
    <!-- 导航栏 -->
    <nav class="header-nav">
        <div class="nav-container">
            <a href="<%= request.getContextPath() %>/index.jsp" class="nav-brand">购物网</a>
            
            <ul class="nav-links">
                <li><a href="<%= request.getContextPath() %>/index.jsp">首页</a></li>
                <li><a href="<%= request.getContextPath() %>/products/list.jsp">商品浏览</a></li>
                <li><a href="<%= request.getContextPath() %>/cart/view/cart.jsp">购物车</a></li>
            </ul>
            
            <div class="user-actions">
                <a href="<%= request.getContextPath() %>/auth/login.jsp" class="btn btn-outline">登录</a>
                <a href="<%= request.getContextPath() %>/auth/register.jsp" class="btn" style="margin-left: 10px;">注册</a>
            </div>
        </div>
    </nav>
    
    <div class="container">
        <div class="page-title">
            <h1>忘记密码</h1>
        </div>
        
        <% if (request.getParameter("error") != null) { %>
            <div class="alert alert-error">
                <%= request.getParameter("error") %>
            </div>
        <% } %>
        
        <% if (request.getParameter("success") != null) { %>
            <div class="alert alert-success">
                <%= request.getParameter("success") %>
                <% if (request.getParameter("resetLink") != null) { %>
                    <br><br>
                    <a href="<%= request.getParameter("resetLink") %>" target="_blank">点击这里重置密码</a>
                <% } %>
            </div>
        <% } %>
        
        <div class="card">
            <div class="card-body">
                <p>请输入您的邮箱地址，我们将向您发送密码重置链接。</p>
                <form action="forgot_password_action.jsp" method="post">
                    <div class="form-group">
                        <label for="email">邮箱地址:</label>
                        <input type="email" id="email" name="email" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                        <input type="submit" value="发送重置链接" class="btn btn-success" style="width: 100%; padding: 0.75rem; font-size: 1.1rem;">
                    </div>
                </form>
            </div>
        </div>
        
        <div style="text-align: center; margin-top: 1.5rem;">
            <p><a href="login.jsp">返回登录</a></p>
        </div>
    </div>
</body>
</html>